<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">   								
	<head> 							
		<link href="style/css.css" rel="stylesheet" type="text/css" />
		<title>码表列表</title>
		<meta http-equiv="X-UA-Compatible" content="IE=7" />
		<%@ include file="../include/jquerylib.jsp" %>
		<script type="text/javascript" src="<%=request.getContextPath() %>/js/DatePicker/WdatePicker.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath() %>/js_css_image/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
		<link rel="stylesheet" type="text/css" media="screen" href="resources/js/mypage.js" />
	       <!-- 删除结果信息返回 -->
	    	<c:if test="${requestScope.message!=null}">
				<script type="text/javascript">
	  	 		     alert('<c:out value="${requestScope.message}"></c:out>');
	  	 		     window.close();
	  			</script>
	        </c:if>
	 
	<script type="text/javascript">
	$(document).ready(function(){
		$("#gridTable").jqGrid({					
			url:'autoFromsAction!getDicviewlist.action?formid=${formid}&temp='+Math.round(Math.random()*10000),
			datatype: "json",
			height: 300,
			autowidth: true, 
			colNames:[${fieldnames}],
			colModel:[${fieldinfos}],
			shrinkToFit:false,
			sortname:'id',
			sortorder:'desc',
			viewrecords:true,
			multiselect: true, // 是否显示复选框
			multiboxonly : true, 
			//gridview: true,  //提升速度
			rownumbers: true,//显示行号
			rownumWidth: 30, //行号的宽度
			rowNum:<%=session.getAttribute("SYS_PAGECOUNT")%>,
			rowList:[15,20,50,200,500],
			toolbar: [false,"top"],
			jsonReader: {
				root:"rows",		// 数据行（默认为：rows）
				page: "page",  	// 当前页
				total: "total",  // 总页数
				records: "records",  // 总记录数
				repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
			},
			prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
			pager:"#gridPager",
			caption: "${formname}"									
	});
				
	 jQuery("#gridTable").jqGrid('navGrid','#gridPager',{add:false,edit:false,del:false,search:false,refresh:false});
		jQuery("#gridTable").jqGrid('navButtonAdd','#gridPager',
					{ 	
					caption: "列状态",                          
					title: "Reorder Columns",                           
					onClickButton : function (){                               
					jQuery("#gridTable").jqGrid('columnChooser');                           
					}
		}); 
		////doResize(); 										
	}); 
	//执行大小
	function doResize() { 
		var ss = getPageSize(); 
		$("#gridTable").jqGrid('setGridHeight', ss.WinH-140);
	} 
	
	
	//修改
	function selectItem(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			  alert("只能选择一条记录!");  
		        return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var fieldnamevalue = row.${fieldname};//获取选中行的id属性
		window.returnValue = fieldnamevalue;
		window.close();
	}
		
	function reload(){
		document.location.reload();
	}
	
	</script>	
	</head>
	<body>

	<form action="" method="post" ">	
			<table style="width: 100%;" class="tableCont">
			<tr>
				<td>
					<input id="update" type='button' value='选 择' onclick='selectItem()' class='button_b' />
				</td>
			</tr>
			<tr>
				<td colspan="4">
					<table id="gridTable"></table>
					<div id="gridPager"></div>
				</td>
			</tr>
		</table>
		</form>
	</body>
</html>
